<?php
class alipay_service_cmbc {

	var $gateway = "https://netpay.cmbchina.com/netpayment/basehttp.dll?PrePayC2?";         //支付接口
	var $parameter;       //全部需要传递的参数
	var $mysign;             //签名

	//构造支付宝外部服务接口控制
	function alipay_service_cmbc($parameter,$sign_type = NULL) {
		$this->parameter      = $parameter;
		$this->sign_type      = $sign_type;
		$sort_array = array();
		$arg = "";
		$sort_array = $this->arg_sort($this->parameter);
	}

	function create_url() {
		$url = $this->gateway;
		$sort_array = array();
		$arg = "";
		$sort_array = $this->arg_sort($this->parameter);
		while (list ($key, $val) = each ($sort_array)) {
			$arg.=$key."=".$val."&";
		}
		$url.= $arg."merchantCode=" .$this->mysign;
		return $url;

	}

	function para_filter($parameter) { //除去数组中的空值和签名模式
		$para = array();
		while (list ($key, $val) = each ($parameter)) {
			if($key == "sign" || $key == "sign_type" || $val == "")continue;
			else	$para[$key] = $parameter[$key];

		}
		return $para;
	}

	function arg_sort($array) {
		ksort($array);
		reset($array);
		return $array;

	}

}
?>